<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学员信息修改</title>
    <link rel="stylesheet" href="../../lib/layui/css/layui.css">
    <link rel="stylesheet" href="../../css/okadmin.css">
</head>
<body style="margin: 0px;padding: 0px;">
<div style="width: 100%;height: 100%;">
    <form  class="layui-from layui-form-pane"  style="width: 550px;height: 500px;margin: 50px auto;box-shadow: #e3e3e3 10px 10px 30px 5px;padding-top: 80px">
        <div style="margin: 0 auto;width: 450px;height: 60px;text-align: center">
            <h2 style="color: #121a65">个人信息修改</h2>
        </div>
        <div style="margin: 0 auto;width: 400px;height: 270px;" class="layui-form">
            <div class="layui-form-item" style="margin-top: 10px">
                <label class="layui-form-label">I&#12288;&#12288;&#12288;D</label>
                <div class="layui-input-block " style="width: 290px;">
                    <input type="text" id="studentId" name="studentId" lay-verify="required"
                           style="background-color: #dcdcdc" disabled
                           placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" style="margin-top: 10px">
                <label class="layui-form-label">当前科目</label>
                <div class="layui-input-block " style="width: 290px;">
                    <input type="text" id="studyStatus" name="studyStatus" lay-verify="required"
                           style="background-color: #dcdcdc" disabled
                           placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" style="margin-top: 30px">
                <div class="layui-inline">
                    <label class="layui-form-label">姓&#12288;&#12288;名</label>
                    <div class="layui-input-block " style="width: 290px;">
                        <input id="fullname" name="fullname" type="text" style="float: left;position: relative;"
                               class="layui-input"
                               placeholder="" lay-verify="required" autocomplete="off">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="margin-top: 30px">
                <div class="layui-inline">
                    <label class="layui-form-label">电&#12288;&#12288;话</label>
                    <div class="layui-input-block " style="width: 290px;">
                        <input id="phone" name="phone" type="text" style="float: left;position: relative;"
                               class="layui-input" lay-verify="phone"
                               placeholder=""  autocomplete="off">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="margin-top: 30px">
                <div class="layui-inline">
                    <label class="layui-form-label">性&#12288;&#12288;别</label>
                    <div class="layui-input-block" style="width: 290px;">
                        <input type="radio" name="agender" id="agender0" value="0" title="女" checked>
                        <input type="radio" name="agender" id="agender1" value="1" title="男">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="margin-top: 30px">
                <label class="layui-form-label">邮&#12288;&#12288;箱</label>
                <div class="layui-input-block " style="width: 290px;">
                    <input id="email" name="email" type="text" style="float: left;position: relative;"
                           class="layui-input" lay-verify="email"
                           placeholder="" autocomplete="off">
                </div>
            </div>
            <div class="layui-form-item" >
                <div class="layui-input-block" >
                    <button type="button" id="updateStudent" lay-submit lay-filter="updateStudent" class="layui-btn" style="width:400px;margin-top:30px; float: right">修&#12288;改
                    </button>
                </div>
            </div>
        </div>

    </form>
</div>
</body>

<script src="../../lib/layui/layui.js"></script>
<script src="../../js/jquery.min.js"></script>
<script src="../../js/application.js"></script>
<script>
    function init(){
        dataSetVal("studentId",user)
        dataSetVal("studyStatus",user,function(val){
            $("#studyStatus").val("科目"+val);
        })
        dataSetVal("fullname",user)
        dataSetVal("phone",user)
        dataSetVal("agender",user,function(value){
            if(value==false){
                $("#agender0").prop('checked',true);
            }else if(value==true){
                $("#agender1").prop('checked',true);
            }
        })
        dataSetVal("email",user)
    }
    layui.use('form', function () {
        var form = layui.form;
        init()
        form.render();

        //监听提交
        form.on('submit(updateStudent)', function(data){
            layer.confirm("确定修改", function (index) {
                var data = {
                    studentId: getVal("studentId"),
                    fullname: getVal("fullname"),
                    phone: getVal("phone"),
                    agender: $('input[name="agender"]:checked').val(),
                    email: getVal("email")
                }
                myAjax(mainUri + "/student/update", data, function (d) {
                    if (d['code'] == 0) {
                        window.sessionStorage.setItem("user", JSON.stringify(d['data']));
                        layer.msg(d['msg'], {
                            icon: 1, time: 1500, end: function () {
                                location.reload();
                            }
                        })
                    }
                })
            })
            return false;
        });

    });
</script>
</html>